import { createRouter, createWebHistory } from 'vue-router'

const routes = [{
        // 路由重定向
        path: '/',
        redirect: '/home'
    },
    // 登录
    {
        path: '/login',
        name: 'login',
        component: () =>
            import ('@/views/Login')
    },
    // 首页
    {
        path: '/',
        name: 'index',
        component: () =>
            import ('@/views/Index'),
        children: [{
                path: '/home',
                name: 'home',
                component: () =>
                    import ('@/views/Home')
            },
            {
                path: '/my',
                name: 'my',
                component: () =>
                    import ('@/views/My')
            }
        ]
    },
    {
        path: '/addUser',
        name: 'addUser',
        component: () =>
            import ('@/views/AddUser')
    },
    // 真伪鉴别
    {
        path: '/identify',
        name: 'identify',
        component: () =>
            import ('@/views/Identify')
    },
    // 搜索
    {
        path: '/search',
        name: 'search',
        props({ query: { searchPath } }) {
            return { searchPath }
        },
        component: () =>
            import ('@/views/Search')
    },
    // 流向查询
    {
        path: '/flow',
        name: '/flow',
        component: () =>
            import ('@/views/Flow')
    },
    // 商店
    {
        path: '/shop',
        name: '/shop',
        component: () =>
            import ('@/views/Shop')
    },
    // 联系我们
    {
        path: '/contact',
        name: '/contact',
        component: () =>
            import ('@/views/Contact')
    }
]

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
})

export default router